package com.sdry.web.controller;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.sdry.model.hpf.Beat;
import com.sdry.model.hpf.Part;
import com.sdry.model.hpf.Position;
import com.sdry.model.hpf.Product;
import com.sdry.model.hpf.Technics;
import com.sdry.model.llm.Classes;
import com.sdry.model.llm.Department;
import com.sdry.model.llm.Team;
import com.sdry.model.llm.User;
import com.sdry.service.hpf.BeatService;
import com.sdry.service.hpf.PartService;
import com.sdry.service.hpf.PositionService;
import com.sdry.service.hpf.ProductService;
import com.sdry.service.hpf.TechnicsService;
import com.sdry.service.llm.ClassesService;
import com.sdry.service.llm.DepartmentService;
import com.sdry.service.llm.EmployeeService;
import com.sdry.service.llm.TeamService;
import com.sdry.service.llm.UserService;
import com.sdry.utils.DateUtil;

import io.swagger.annotations.ApiOperation;

/**
 * 
 * @ClassName:JumpPageController
 * @Description:跳转页面
 * @Author tdd
 * @Date 2018年4月25日下午5:05:43
 * @version 1.0
 */
@Controller
public class JumpPageController {
	/******************************基础模块******************************/
	@Resource
	private ProductService productService;//注入产品Service
	@Resource
	private BeatService beatService;//注入节拍Service
	@Resource
	private TechnicsService technicsService;//注入工艺Service
	@Resource
	private PositionService positionService;  //注入工位Service
	@Resource
	private PartService partService;  //注入零件Service
	@Resource
	private EmployeeService empService;  //注入员工Service
	@Resource
	private TeamService teamService;  //注入班组Service
	@Resource
	private DepartmentService departmentService;  //注入部门Service
	@Resource
	private UserService userService;  //注入人员Service
	@Resource
	private ClassesService classesService;  //注入班次Service
	
	
	/**
	 * 跳转型号管理页面
	 * 
	 * @return /basics/kinds
	 *//*
	@ApiOperation(value = "型号管理")
	@RequestMapping("/jumpPage/kinds")
	public String kinds() {
		
		return "/basics/kinds";
	}*/
	/**
	 * 跳转型号管理页面
	 * 
	 * @return /basics/kinds
	 */
	@ApiOperation(value = "型号管理")
	@RequestMapping("/jumpPage/kinds")
	public ModelAndView kinds() {
		ModelAndView mv = new ModelAndView();
		List<Product> productList = productService.listAllProduct(new Product());
		mv.addObject("pList", productList);
		mv.setViewName("/basics/kinds");
		return mv;
	}
	/**
	 * 跳转产线管理页面
	 * 
	 * @return /basics/workPosition
	 */
	@ApiOperation(value = "产线管理")
	@RequestMapping("/jumpPage/productionLine")
	public String productionLine() {
		
		return "/basics/productionLine";
	}
	/**
	 * 跳转工位管理页面
	 * 
	 * @return /basics/workPosition
	 *//*
	@ApiOperation(value = "工位管理")
	@RequestMapping("/jumpPage/workPosition")
	public String workPosition() {
		
		return "/basics/workPosition";
	}*/
	
	/**
	 * 跳转工位管理页面
	 * 
	 * @return /basics/workPosition
	 */
	@ApiOperation(value = "工位管理")
	@RequestMapping("/jumpPage/workPosition")
	public ModelAndView workPosition() {
		ModelAndView mv = new ModelAndView();
		List<Beat> beatList = beatService.listAllBeat(new Beat());
		mv.addObject("beatList", beatList);
		mv.setViewName("/basics/workPosition");
		return mv;
	}
	/**
	 * 跳转零件管理页面
	 * 
	 * @return /basics/part
	 */
	@ApiOperation(value = "零件管理")
	@RequestMapping("/jumpPage/part")
	public String part() {
		
		return "/basics/part";
	}
	/**
	 * 跳转BOM管理页面
	 * 
	 * @return /basics/bom
	 */
	/*@ApiOperation(value = "BOM管理")
	@RequestMapping("/jumpPage/bom")
	public ModelAndView bom() {
		ModelAndView mv = new ModelAndView();
		List<Product> productList = productService.listAllProduct(new Product());
		mv.addObject("pList", productList);
		mv.setViewName("/basics/bomNew");
		return mv;
	}*/
	@ApiOperation(value = "BOM管理")
	@RequestMapping("/jumpPage/bom")
	public String bom() {
		
		return "/basics/bomNew";
	}
	/**
	 * 跳转节拍管理页面
	 * 
	 * @return /basics/bom
	 */
	@ApiOperation(value = "节拍管理")
	@RequestMapping("/jumpPage/rhythm")
	public String rhythm() {
		
		return "/basics/rhythm";
	}
	/**
	 * 跳转系统属性页面
	 * 
	 * @return /basics/attributes
	 */
	@ApiOperation(value = "系统属性")
	@RequestMapping("/jumpPage/attributes")
	public String attributes() {
		
		return "/basics/attributes";
	}
	/**
	 * 跳转工艺管理页面
	 * 
	 * @return /basics/crafts
	 *//*
	@ApiOperation(value = "工艺管理")
	@RequestMapping("/jumpPage/crafts")
	public String crafts() {
		
		return "/basics/crafts";
	}*/
	/**
	 * 跳转工艺管理页面
	 * 
	 * @return /basics/crafts
	 */
	@ApiOperation(value = "工艺管理")
	@RequestMapping("/jumpPage/crafts")
	public ModelAndView crafts() {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/basics/crafts");
		return mv;
	}
	/**
	 * 跳转标签管理页面
	 * 
	 * @return /basics/label
	 */
	@ApiOperation(value = "标签管理")
	@RequestMapping("/jumpPage/label")
	public ModelAndView label() {
		ModelAndView mv = new ModelAndView();
		List<Product> productList = productService.listAllProduct(new Product());
		List<Part> partList = partService.listAllPart();
		List<Position> positionList = positionService.listAllPosition();
		mv.addObject("positionList", positionList);
		mv.addObject("productList", productList);
		mv.addObject("partList", partList);
		mv.setViewName("/basics/labelNew");
		return mv;
	}
	
	/**
	 * 跳转台车管理页面
	 * 
	 * @return /basics/trolley
	 */
	@ApiOperation(value = "台车管理")
	@RequestMapping("/jumpPage/trolley")
	public String trolley() {
		
		return "/basics/trolley";
	}
	
	/**
	 * 跳转设备管理页面
	 * 
	 * @return /basics/equipment
	 */
	@ApiOperation(value = "设备管理")
	@RequestMapping("/jumpPage/equipment")
	public String equipment() {
		
		return "/basics/equipment";
	}
	/**
	 * 跳转产品信息页面
	 * 
	 * @return /basics/product
	 */
	@ApiOperation(value = "产品信息")
	@RequestMapping("/jumpPage/product")
	public String product() {
		
		return "/basics/product";
	}
	/**
	 * 跳转物料页面
	 * 
	 * @return /basics/materiel
	 */
	@ApiOperation(value = "物料信息")
	@RequestMapping("/jumpPage/materiel")
	public String materiel() {
		
		return "/basics/materiel";
	}
	
	
	
	/******************************权限模块******************************/
	
	/**
	 * 跳转部门管理页面
	 * 
	 * @return /jurisdiction/department
	 */
	@ApiOperation(value = "部门管理")
	@RequestMapping("/jumpPage/department")
	public ModelAndView department() {
		ModelAndView mv = new ModelAndView();
		List<User> allEmp = empService.listAllEmp();
		mv.addObject("allEmp", allEmp);
		mv.setViewName("/llm/department");
		return mv;
	}
	/**
	 * 跳转用户管理页面
	 * 
	 * @return /jurisdiction/user
	 */
	@ApiOperation(value = "用户管理")
	@RequestMapping("/jumpPage/user")
	public ModelAndView user(HttpSession session) {
		ModelAndView mv = new ModelAndView();
		List<Department> allDepartment = departmentService.listAllDepartment();
		mv.addObject("allDepartment", allDepartment);
		mv.setViewName("/llm/user");
		return mv;
	}
	
	/**
	 * 跳转角色管理页面
	 * 
	 * @return /jurisdiction/role
	 */
	@ApiOperation(value = "角色管理")
	@RequestMapping("/jumpPage/role")
	public String role() {
		
		return "/llm/role";
	}
	/**
	 * 跳转密码管理页面
	 * 
	 * @return /jurisdiction/passwork
	 */
	@ApiOperation(value = "密码管理")
	@RequestMapping("/jumpPage/passwork")
	public String passwork() {

		return "/jurisdiction/passwork";
	}
	/******************************登陆模块******************************/
	/**
	 * 首页
	 * @return
	 */
	/*@ApiOperation(value = "主页")
	@RequestMapping(value = "/main", method = RequestMethod.GET)
	public String main() {

		return "/main";
	}*/

	/******************************标签管理******************************/

	/**
	 * 物料标签
	 * @return
	 */
	@ApiOperation(value = "物料标签")
	@RequestMapping(value = "/jumpPage/materielLabel")
	public String materielLabel() {

		return "label/materielLabel";
	}
	/**
	 * 产品标签
	 * @return
	 */
	@ApiOperation(value = "产品标签")
	@RequestMapping(value = "/jumpPage/productLabel")
	public String productLabel() {

		return "label/productLabel";
	}
	/**
	 * 文本标签
	 * @return
	 */
	@ApiOperation(value = "文本标签")
	@RequestMapping(value = "/wb")
	public String wb() {

		return "wb";
	}

	/**
	 * 文本标签
	 * @return
	 */
	@ApiOperation(value = "文本标签")
	@RequestMapping(value = "/tj")
	@ResponseBody
	public String wb(String wb) {
		wb = wb + "<h1><strong>value</strong></h1>";
		return wb;
	}



	/****************************测试*********************************/
	/***************日志******************/
	/**
	 * 跳转操作日志管理页面
	 *
	 * @return /log/staffLog
	 */
	@RequestMapping("/jumpPage/staffLog")
	public String staffLog() {

		return "/llm/logMana";
	}

	/**
	 * 跳转异常日志管理页面
	 *
	 * @return /log/exceptionLog
	 */
	@RequestMapping("/jumpPage/exceptionLog")
	public String exceptionLog() {

		return "/llm/exceptionLog";
	}
	


	/*****************测试*****************/
	/**
	 * 跳转工艺卡管理页面
	 *
	 * @return /basics/referenceNew3
	 */
	@RequestMapping("/jumpPage/reference")
	public ModelAndView reference() {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/basics/referenceNew3");
		return mv;
	}
	
	/**
	 * 跳转工艺详情页面
	 *
	 * @return /basics/craftDetails
	 */
	@RequestMapping("/jumpPage/craftDetails")
	public ModelAndView craftDetails() {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/basics/craftDetails");
		return mv;
	}
	
	/**
	 * 跳转作业管理页面
	 *
	 * @return /basics/reference
	 */
	@RequestMapping("/jumpPage/workManage")
	public ModelAndView workManange(String positionName) {
		ModelAndView mv = new ModelAndView();
		mv.addObject("positionName", positionName);
		mv.setViewName("/llm/work");
		return mv;
	}
	
	/**
	 * 跳转包装单位页面
	 *
	 * @return /basics/packingUnit
	 */
	@RequestMapping("/jumpPage/packingUnit")
	public String packingUnit() {

		return "/basics/packingUnit";
	}
	/**
	 * 跳转预警管理页面
	 *
	 * @return /basics/earlyWarning
	 */
	@RequestMapping("/jumpPage/earlyWarning")
	public ModelAndView earlyWarning() {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/basics/earlyWarning");
		return mv;
	}


	/***************员工管理***************/
	/**
	 * 跳转班次管理页面
	 *
	 * @return /llm/employee
	 */
	@RequestMapping("/jumpPage/staff")
	public ModelAndView staff() {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/llm/classes");
		return mv;
	}

	/**
	 * 跳转班组管理页面
	 *
	 * @return /llm/team
	 */
	@RequestMapping("/jumpPage/team")
	public ModelAndView team() {
		ModelAndView mv = new ModelAndView();
		List<User> allUser = empService.listAllEmp();
		List<Team> allTeam = teamService.listAllTeam();
		List<Classes> allClasses = classesService.listPageClasses("");
		mv.addObject("allUser", allUser);
		mv.addObject("allTeam", allTeam);
		mv.addObject("allClasses", allClasses);
		mv.setViewName("/llm/team");
		return mv;
	}

	/**
	 * 跳转班组记录页面
	 *
	 * @return /team/teamRecord
	 */
	@RequestMapping("/jumpPage/teamRecord")
	public ModelAndView teamRecord() {
		ModelAndView mv = new ModelAndView();
		List<Position> listPosition = positionService.listAllPosition();
		List<User> listEmp = empService.listAllEmp();
		List<Team> listTeam = teamService.listAllTeam();
		mv.addObject("listPosition", listPosition);
		mv.addObject("listEmp", listEmp);
		mv.addObject("listTeam", listTeam);
		mv.setViewName("/llm/teamRecord2");
		return mv;
	}
	
	/**
	 * 跳转排产单
	 *
	 * @return /basics/packingUnit
	 */
	@RequestMapping("/jumpPage/scheduling")
	public String scheduling() {

		return "/llm/monthshedu5";
	}
	
	
	/**********Workplace
	 * @throws ParseException *************************/
	@RequestMapping("/jumpPage/w1")
	public String w1(Model model) throws ParseException{
		SimpleDateFormat   sDateFormat   =   new   SimpleDateFormat("yyyy-MM-dd HH:mm:ss");   
        String   date   =   sDateFormat.format(new Date());
		model.addAttribute("format", date);
		
		return "/workplace/w1";
	}
	@RequestMapping("/jumpPage/w2")
	public String w2(Model model) throws ParseException{
		SimpleDateFormat   sDateFormat   =   new   SimpleDateFormat("yyyy-MM-dd HH:mm:ss");   
        String   date   =   sDateFormat.format(new Date());
		model.addAttribute("format", date);

		return "/workplace/w2";
	}
	@RequestMapping("/jumpPage/w3")
	public String w3(Model model) throws ParseException{
		SimpleDateFormat   sDateFormat   =   new   SimpleDateFormat("yyyy-MM-dd HH:mm:ss");   
        String   date   =   sDateFormat.format(new Date());
		model.addAttribute("format", date);

		return "/workplace/w3";
	}
	
	/***
	 * 固化绑定
	 * @return
	 * @throws ParseException 
	 */
	@RequestMapping("/jumpPage/w4")
	public String w4(Model model) throws ParseException {
		String format = DateUtil.dateFormat2();
		model.addAttribute("format",format);
		return "/jyy/w4";
	}
	/***
	 * 固化开始
	 * @return
	 */
	@RequestMapping("/jumpPage/w42")
	public String w42(Model model) {
		String format = DateUtil.dateFormat2();
		model.addAttribute("format",format);
		return "/jyy/w42";
	}
	
	/***
	 * 切割
	 * @param model
	 * @return
	 */
	@RequestMapping("/jumpPage/w5")
	public String w5(Model model) {
		String format = DateUtil.dateFormat2();
		model.addAttribute("format",format);
		return "/jyy/w5";
	}
	@RequestMapping("/jumpPage/w6")
	public String w6() {
		
		return "/workplace/w6";
	}
	@RequestMapping("/jumpPage/w7")
	public String w7() {
		
		return "/workplace/w7";
	}
	@RequestMapping("/jumpPage/w8")
	public String w8() {
		
		return "/workplace/w8";
	}
	@RequestMapping("/jumpPage/w9")
	public String w9() {
		
		return "/workplace/w9";
	}
	@RequestMapping("/jumpPage/revoke1")
	public String revoke1() {
		
		return "/workplace/revoke1";
	}
	@RequestMapping("/jumpPage/revoke11")
	public String revoke11() {
		
		return "/workplace/revoke11";
	}
	@RequestMapping("/jumpPage/revoke2")
	public String revoke2() {
		
		return "/workplace/revoke2";
	}
	@RequestMapping("/jumpPage/revoke3")
	public String revoke3() {
		
		return "/workplace/revoke3";
	}
	//报表开始（llm）
	
	/**
	 * 人员报表
	 * @Title:productionReport   
	 * @return
	 */
	@RequestMapping("/jumpPage/userReport")
	public ModelAndView userReport() {
		ModelAndView mv = new ModelAndView();
		List<User> allUser = empService.listAllUserInTeam();
		mv.addObject("allUser", allUser);
		mv.setViewName("/llm/userReport");
		return mv;
	}
		
	/**
	 * 综合日报表
	 * @Title:productionReport2   
	 * @return
	 */
	@RequestMapping("/jumpPage/Comprehensive")
	public ModelAndView WeeklyProductionReport2() {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/lqy/productReport");
		return mv;
	}
	//报表结束（llm）
}
